package com.tac.controller.scm;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.scm.PurchasePlan;
import com.tac.pojo.scm.PurchasePlanDetails;
import com.tac.service.scm.PurchasePlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RequestMapping("/purchasePlan")
@Api(tags = "供应链SCM--采购管理--采购计划")
@CrossOrigin
@RestController
public class PurchasePlanController {

    @Autowired
    private PurchasePlanService purchasePlanService;

    //查看采购计划列表
    @ApiOperation("查看采购计划列表")
    @GetMapping("/getList")
    public Result<PageInfo<PurchasePlan>> getList(Integer pageNum, Integer pageSize, String documentNumber, String applicant, @DateTimeFormat(pattern = "yyyy-MM-dd") Date applicationDateStart,@DateTimeFormat(pattern = "yyyy-MM-dd")  Date applicationDateEnd
            , String applicationStatus, String reviewer, @DateTimeFormat(pattern = "yyyy-MM-dd") Date reviewDateStart, @DateTimeFormat(pattern = "yyyy-MM-dd") Date reviewDateEnd, String reviewStatus){
        return purchasePlanService.getList(pageNum,pageSize,documentNumber, applicant, applicationDateStart, applicationDateEnd, applicationStatus, reviewer, reviewDateStart, reviewDateEnd, reviewStatus);
    }

    //修改采购计划 能修改备注，审核状态（提交）
    @ApiOperation("修改采购计划")
    @PutMapping("/update")
    public Result update(@RequestBody PurchasePlan purchasePlan){
        return purchasePlanService.update(purchasePlan);
    }

    //删除采购计划
    @ApiOperation("删除采购计划")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody  List<Integer> ids){
        return purchasePlanService.remove(ids);
    }

    //添加采购计划 给个申请状态，备注就行
    @ApiOperation("添加采购计划")
    @PostMapping("/save")
    public Result save(@RequestBody  PurchasePlan purchasePlan){
        return purchasePlanService.save(purchasePlan);
    }




    //采购计划审核  给审核意见、审核状态、
    @PutMapping("/updateByReview")
    @ApiOperation("采购计划审核")
    public Result updateByReview(@RequestBody  PurchasePlan purchasePlan){
        return purchasePlanService.updateByReview(purchasePlan);
    }



    //采购计划详情删除
    @ApiOperation("采购计划详情删除")
    @DeleteMapping("/remove2")
    public Result remove2(@RequestBody List<Integer> ids){
        return purchasePlanService.remove2(ids);
    }
    //采购计划详情修改
    @ApiOperation("采购计划详情修改")
    @PutMapping("/update2")
    public Result update2(@RequestBody PurchasePlanDetails purchasePlanDetails){
        return purchasePlanService.update2(purchasePlanDetails);
    }
    //采购计划详情添加
    @ApiOperation("采购计划详情添加")
    @PostMapping("/save2")
    public Result save2(@RequestBody PurchasePlanDetails purchasePlanDetails){
        return purchasePlanService.save2(purchasePlanDetails);
    }
}
